from peewee import CharField, TextField
from playhouse.shortcuts import model_to_dict

from models.base_model import BaseModel


class EnumData(BaseModel):
    key = CharField(null=True, verbose_name='处理结果')
    value = CharField(null=True, verbose_name='处理结果')
    type = CharField(null=True, verbose_name='处理结果')

    def get_standard_obj(self):
        enum_data = model_to_dict(self, only=[EnumData.key, EnumData.value])
        enum_data = {'label': enum_data['key'],
                     "value": enum_data['value'],
                     "dictType": self.type}
        return enum_data

    class Meta:
        db_table = 'xingxiu_enum_data'
